package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealAndDish;
import com.sky.entity.SetmealDish;
import com.sky.result.Result;
import com.sky.service.SetmealDishService;
import com.sky.service.SetmealService;
import com.sky.vo.DishVO;
import com.sky.vo.SetmealVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @projectName: sky-take-out
 * @package: com.sky.controller.user
 * @className: UserSetmealController
 * @author: Eric
 * @description: TODO
 * @date: 2023/9/26 16:47
 * @version: 1.0
 */
@RestController
@RequestMapping("/user/setmeal")
@Slf4j
public class UserSetmealController {
    @Autowired
    private SetmealService setmealService;
    @Autowired
    private SetmealDishService setmealDishService;

    @GetMapping("/list")
    public Result<List<SetmealVO>> SetmealList(Long categoryId){
        List<SetmealVO> setmealVOList = setmealService.selectByCategoryId(categoryId);
        return Result.success(setmealVOList);
    }

    @GetMapping("/dish/{id}")
    public Result<List<DishVO>> queryDishes(@PathVariable Long id){
        List<DishVO> dishList = setmealDishService.queryDishes(id);
        return Result.success(dishList);
    }

}
